package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	Title  string  `gorm:"type:varchar(20);not null;index:ip_idx commit:'商品标题'"`
	Price  float64 `gorm:"type:decimal(10,2);not null;index:ip_idx commit:'商品价格'"`
	Cover  string  `gorm:"type:varchar(255);not null;index:ip_idx commit:'商品封面'"`
	Stock  int64   `gorm:"type:int;not null;index:ip_idx commit:'商品库存'"`
	Starts string  `gorm:"type:enum('已上架','未上架');not null;index:ip_idx commit:'商品状态'"`
	TypeId int64   `gorm:"type:int;not null;index:ip_idx commit:'分类ID'"`
	UserId int64   `gorm:"type:int;not null;index:ip_idx commit:'用户ID'"`
}

func (g *Goods) Create() error {
	return DB.Create(&g).Error
}
func (g *Goods) Find(GoodsId int) error {
	return DB.Where("id=?", GoodsId).Find(&g).Error
}
